package org.abacus.http;

import org.junit.Test;

public class HttpTest {

	@Test
	public void baidu() {
		Request<String, String> req = new StringHttpRequest("http://localhost:8080/session/SessionServlet?login=3&sid=1");
		req.setRequestMethod("GET");
		req.setCookie("JSESSIONID=D2EFB9FA956214764193941867535D4A; Path=/session/; HttpOnly");
		req.setCharsetEncoding("GBK");
		req.setRequestProperty("login", "3");
		req.setRequestProperty("sid", req.getCookie());
		Response<String> s = req.doWork(null);
		System.out.println(req.getCookie());
		System.out.println(s.getResponse());
	}

	@Test
	public void goolge() {
		Request<String, String> req = new StringHttpRequest("http://www.google.com");
		req.setRequestMethod("GET");
		req.setCharsetEncoding("GBK");
		Response<String> s = req.doWork(null);
		System.out.println(req.getCookie());
		System.out.println(s.getResponse());
	}
	@Test
	public void menus() {
		Request<String, String> req = new StringHttpRequest("http://127.0.0.1:8080/chaoyangli.abacus/api/menu/list.json");
		req.setRequestMethod("POST");
		req.setCharsetEncoding("UTF-8");
		String a="{\"page\":{\"start\":0,\"limit\":20}}";
		Response<String> s = req.doWork(a);
		System.out.println(req.getCookie());
		System.out.println(s.getResponse());
	}
}
